#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
void printV(int val) { cout << val << endl; }

int main() {

  vector<int> v;
  v.push_back(10);
  v.push_back(20);
  v.push_back(30);
  v.push_back(40);

  // 三种遍历vector的方法
  vector<int>::iterator begin = v.begin();
  vector<int>::iterator end = v.end();
  while (begin != end) {
    cout << *begin << " ";
    begin++;
  }
  cout << "\n===========" << endl;

  for_each(v.begin(), v.end(), printV);
  cout << "===========" << endl;

  for (vector<int>::iterator it = v.begin(); it != v.end(); it++) {
    cout << *it << " ";
  }

  return 0;
}
